@import "_variables";

/**
 * responsive breaks
 */
@break-level-1: 320px;
@break-level-2: 425px;
@break-level-3-1: 680px;
@break-level-3: 768px;
@break-level-4: 900px;
@break-level-5: 980px;
@break-level-6: 1024px;

body {
    background: #F2F2F2;
    background-image: url('');
    background-attachment: scroll;
    font-family: @font-content;
    font-size: 1.125rem;
    line-height: 1.7;
    @media only screen and (max-width: @break-level-3) {
        font-size: 1rem;
        line-height: 1.6;
    }

    a {
        outline: none;
    }
}

h1,h2,h3,h4,h5,h6 {
    font-family: @font-header;
    position: relative;

    &:hover .header-anchor::after {
        visibility: visible;
    }

    .header-anchor {
        visibility: hidden;
        position: absolute;
        right: 100%;
        color: @color-ignore;
        border: none;

        &:hover {
            border: none;
        }
    }
}

h2 .header-anchor::after {
    content: '# ';
}

h3 .header-anchor::after {
    content: '## ';
}

h4 .header-anchor::after {
    content: '### ';
}

.wrapper{
    max-width: 960px;
    margin: 0 auto;
    @media only screen and (max-width: @break-level-6) {
        max-width: 800px;
    }
    @media only screen and (max-width: @break-level-5) {
        max-width: 680px;
    }

    @media only screen and (max-width: @break-level-3) {
        max-width: auto;
    }
}

.post-main, .post-entry, .page-navigator {
    border: 1px solid lightgray;
    box-shadow: 0 0 2px lightgray;
    background: white;
    color: #444;
    padding: 3% 6%;
    position: relative;

    @media only screen and (max-width: @break-level-3) {
        padding: 25px 50px;
    }

    @media only screen and (max-width: @break-level-2) {
        padding: 25px 5px 25px 5px;
    }
}

.post-main {
    margin: 5% auto;
    @media only screen and (max-width: @break-level-5) {
        margin: auto;
    }
}

.post-entry {
    margin: 1em auto;

    @media only screen and (max-width: @break-level-3) {
        margin: 25px auto;
    }

    &:first-child {
        margin-top: 0;
    }
}

.page-navigator {
    padding: .5em 0;
}

.post-entry {
    .post-meta {
        display: flex;
        justify-content: space-between;
        color: @color-ignore;
        .post-time {
            flex-shrink: 0;
        }
        .post-tag-link {
            display: inline-block;
            color: @color-ignore;
            margin: 0 4px;
            &::before {
                content: '#';
            }

            &:hover {
                color: @color-main-link;
                border-color: @color-main-link;
            }
        }
    }

}

.nav {
    display: flex;
    flex-direction: row-reverse;
    justify-content: space-between;

    @media only screen and (max-width: @break-level-2) {
        flex-wrap: wrap;
    }

    .post-meta {
        color: @color-ignore;
    }

    .post-tag-link {
        color: @color-ignore;
        margin: 0 4px;
        &::before {
            content: '#';
        }
        &:hover {
            color: @color-main-link;
            border-color: @color-main-link;
        }
    }

    .post-tags {
        display: inline-block;
    }

    .post-time {
        display: inline-block;
        font-size: 0.8em;
        padding-left: 4px;
    }
}

.sidebar-nav-item {
    text-decoration: none;
    color: @color-ignore;
    margin: 0 4px;

    &:hover {
        color: @color-main-link;
        border-color: @color-main-link;
    }
}

h2 {
    border-bottom: 1px solid lightgray;
    font-weight: 500;
    margin: 1em 0 .2em;
}

article {
    img, video, object[type="image/svg+xml"] {
        max-width: 100%;
        border: 1px solid lightgray;
        display: block;
    }

    img.no-border, object[type="image/svg+xml"].no-border {
        border: none;
    }

    img.center, video.center, object[type="image/svg+xml"].center {
        margin: 0 auto;
        display: block;
    }

    img.full, video.full, object[type="image/svg+xml"].full {
        width: 100%;
    }

    a {
        color: @color-main-link;
        text-decoration: none;
        opacity: 0.9;

        transition: all .2s;
        border-bottom: .08em solid lightgray;
        &:hover {
            border-bottom: .16em solid @color-main-link-hover;
            color: @color-main-link-hover;
        }
    }

    // blockquote
    blockquote {
        margin-left: 0;
        padding: 0 @article-padding;
        border-left: 5px solid @color-underscore;

        // block footer
        footer {
            font-size: 85%;
            cite::before {
                content: "—";
                padding: 0 0.5em;
                font-style: italic;
            }
        }

        ol, ul {
            padding-left: inherit;
        }
    }

    blockquote.pullquote.left {
        border: none;
        margin: 0 1em 0 .5em;
        width: 45%;
    }

    blockquote.pullquote.right {
        border: none;
        margin: 0 .5em 0 1em;
        width: 45%;
    }

    .left, .alignleft {
        float: left;
    }

    .right, .alignright {
        float: right;
    }


    .video-container {
        position: relative;
        padding-top: 56.9%; // 16:9
        height: 0;
        overflow: hidden;
        iframe, object, embed {
            position: absolute;
            top: 0;
            left: 0;
            height: 100%;
            width: 100%;
            margin-top: 0;
        }
    }

    // cancel dangling list for the first level
    ol, ul {
        padding-left: 0;
        @media only screen and (max-width: @break-level-2) {
            padding-left: 2em ;
        }
        ol, ul {
            padding-left: 3em;
        }
    }

    // list
    li p {
        margin-top: 0;
        margin-bottom: 0;
    }

    // inline code
    code {
        background: #EEE;
        border: 1px solid lightgray;
        border-radius: 3px;
        font-size: @font-size-code;
    }

    pre {
        font-size: @font-size-code;
    }

    // table
    table {
        width: 100%;
        border-collapse: collapse;
        border-spacing: 0;
        vertical-align: middle;

        th {
            text-align: left;
            background: #333;
            color: #EEE;
        }

        th, td {
            padding: 5px 8px;
            border: 1px solid #ddd;
        }

        tr:nth-child(2n) {
            background-color: #f2f2f2;
        }
    }

    .article-gallery a.article-gallery-img {
        width: 100%;
        display: none;

        &:first-child {
            display: block;
        }

        img {
            width: 100%;
        }
    }

    hr {
        border: none;
        border-bottom: 1px solid lightgray;
    }
}


/* menu button on small screen */
#menu {
    position: absolute;
    top: -9999px;
    left: -9999px;
}

#toggle-menu{
    cursor: pointer;
    user-select: none;
    display: none; // large display, hide it
}

@media only screen and (max-width: @break-level-2) {

    #toggle-menu {
        display: block;
        color: @color-ignore;
        font-size: 2em;
        padding: 0 .5em;
        float: right;
    }

    .nav-items, .subtitle {
        display: none;
    }

    #menu:checked ~ .nav-items {
        display: block;
        text-align: right;

        a {
            color: @color-main-link;

            // enable decoration
            &:last-child::after {
                display: block;
            }
        }
    }
}

.page-navigator {
    overflow: hidden;
    text-align: center;
    color: #777;
    .page-number {
        display: inline-block;
    }

    .current {
        color: #2F6EB6;
    }

    .page-number, .current, .prev, .next {
        padding: 0.1em 0.5em;
    }

    .prev {
        float: left;
    }

    .next {
        float: right;
    }


    a {
        color: inherit;
        text-decoration: none;
        &:hover {
            background: lightgray;
            color: @color-main-link;
        }
    }
}

// toc
details {
    user-select: none;
    padding-bottom: 1px;

    background: #EEE;

    ol {
        list-style: none;
        padding-left: 40px;
        ol, ul {
            padding-left: 2em;
        }
    }

    summary {
        padding-left: 8px;
        outline: none;
        cursor: pointer;
    }

    &[open] summary {
        background: #DDD;
    }
}

details[open] summary ~ * {
  animation: sweep .2s ease-in-out;
}

@keyframes sweep {
  0%    {opacity: 0; margin-left: -10px}
  100%  {opacity: 1; margin-left: 0px}
}

// header
.header {
    margin-top: 2em;
    display: flex;
    @media only screen and (max-width: @break-level-2) {
        margin-top: 0;
        display: block;
    }
    align-items: baseline;
    justify-content: space-between;
    text-decoration: none;
    color: @color-ignore;

    #logo {
        font-family: @font-blog-title;
        font-size: 2em;
        color: gray;
        text-decoration: none;
    }

    .subtitle {
        padding-left: .5em;
    }

    .nav-items {
        color: gray;
    }
}

// footer
.footer {
    display: flex;
    justify-content: space-between;
    margin-top: 1em;
    align-items: flex-end;
    color: #AAA;

    @media only screen and (max-width: @break-level-3) {
        flex-direction: column;
        align-items: center;

        .social {
            padding: 1em .4em;
        }

        .footer-content {
            padding: .5em .2em;
            text-align: center
        }
    }

    a {
        color: #AAA;

        &:hover {
            color: @color-main-link;
        }
    }

    .social {
        display: flex;
        align-items: center;
        justify-content: center;
        color: gray;

        a {
            display: inline-block;
            padding: 0 6px;
            font-size: 20px;

            transition: all .2s ease-in-out;

            &:hover {
                background: lightgray;
                color: @color-main-link;
            }
        }
    }
}

// archive
.all-categories, .all-tags {
    &::before {
        font-family: FontAwesome;
        float: left;
        margin-right: 1em;
    }

    ul.tag-box {
        list-style: none;
        display: flex;
        flex-wrap: wrap;

        li {
            margin: .2em .2em;
            a {
                display: inline;
                text-decoration: none;
                border: 1px dashed #CCC;
                border-radius: 3px;
                margin: .2em;
                padding: .1em .3em;
                outline: none;

                transition: none;

                span {
                    font-size: 0.8em;
                    border-left: 1px solid #CCC;
                    margin-left: .3em;
                    padding: 0 .3em;
                }

                &:hover {
                    background: #666;
                    color: #EEE;
                }
            }
        }
    }
}

.post-archive {
    .date {
        padding-right: 1em;
        font-size: .8em;
    }
}

.all-categories::before {
    content: "\f07b";
}

.all-tags::before {
    content: "\f02c";
}


// loading spinner
.loading {
  text-align: center;
}

.spinner {
  display: inline-block;
  position: relative;
  width: 64px;
  height: 64px;
}
.spinner div {
  display: inline-block;
  position: absolute;
  left: 6px;
  width: 13px;
  background: #CCC;
  animation: spinner 1.2s cubic-bezier(0, 0.5, 0.5, 1) infinite;
}
.spinner div:nth-child(1) {
  left: 6px;
  animation-delay: -0.24s;
}
.spinner div:nth-child(2) {
  left: 26px;
  animation-delay: -0.12s;
}
.spinner div:nth-child(3) {
  left: 45px;
  animation-delay: 0;
}
@keyframes spinner {
  0% {
    top: 6px;
    height: 51px;
  }
  50%, 100% {
    top: 19px;
    height: 26px;
  }
}
